'use client';

import Link from 'next/link';

interface Brand {
  brand: string;
  name: string;
  alphabet: string;
  country: string;
  hot: string;
  desc: string;
  story: string;
}

interface BrandCardProps {
  brand: Brand;
  showDetails?: boolean;
}

export default function BrandCard({ brand, showDetails = false }: BrandCardProps) {
  return (
    <Link
      href={`/brands/${brand.brand}`}
      className="block group"
    >
      <div className="bg-white rounded-lg shadow-sm p-6 hover:shadow-lg transition-all duration-300 transform hover:-translate-y-1 border border-gray-100 hover:border-blue-200">
        {/* Header */}
        <div className="flex items-center justify-between mb-4">
          <div className="flex items-center space-x-4">
            <div className="relative">
              <div className="w-16 h-16 bg-gradient-to-br from-blue-500 to-purple-600 rounded-full flex items-center justify-center text-white text-2xl font-bold shadow-lg">
                {brand.alphabet}
              </div>
              {brand.hot === '1' && (
                <div className="absolute -top-1 -right-1">
                  <span className="bg-red-500 text-white text-xs px-2 py-1 rounded-full font-semibold shadow-sm">
                    热门
                  </span>
                </div>
              )}
            </div>
            <div>
              <h3 className="text-xl font-bold text-gray-900 group-hover:text-blue-600 transition-colors">
                {brand.name}
              </h3>
              <p className="text-gray-600 text-sm">
                {brand.country} · {brand.brand}
              </p>
            </div>
          </div>
          
          <div className="text-right">
            <div className="text-gray-400 group-hover:text-blue-400 transition-colors">
              <svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5l7 7-7 7" />
              </svg>
            </div>
          </div>
        </div>

        {/* Description */}
        {showDetails && (
          <div className="mb-4">
            <p className="text-gray-700 leading-relaxed text-sm line-clamp-3">
              {brand.desc}
            </p>
          </div>
        )}

        {/* Stats */}
        <div className="grid grid-cols-3 gap-2 text-center">
          <div className="bg-blue-50 rounded-lg p-2">
            <div className="text-blue-600 font-semibold text-sm">车型</div>
            <div className="text-blue-900 font-bold">8+</div>
          </div>
          <div className="bg-green-50 rounded-lg p-2">
            <div className="text-green-600 font-semibold text-sm">价格</div>
            <div className="text-green-900 font-bold text-xs">20-100万</div>
          </div>
          <div className="bg-purple-50 rounded-lg p-2">
            <div className="text-purple-600 font-semibold text-sm">评分</div>
            <div className="text-purple-900 font-bold">4.8</div>
          </div>
        </div>

        {/* Story Preview */}
        {showDetails && (
          <div className="mt-4 pt-4 border-t border-gray-100">
            <div className="flex items-center justify-between">
              <span className="text-xs text-gray-500 font-medium">品牌故事</span>
              <span className="text-xs text-blue-500">阅读更多</span>
            </div>
            <p className="text-gray-600 text-xs mt-1 line-clamp-2">
              {brand.story.slice(0, 80)}...
            </p>
          </div>
        )}

        {/* Hover Effect Indicator */}
        <div className="absolute inset-0 rounded-lg bg-gradient-to-r from-blue-50 to-purple-50 opacity-0 group-hover:opacity-100 transition-opacity duration-300 -z-10" />
      </div>
    </Link>
  );
}